/*订单预览页*/
var OrderPreview = {};

OrderPreview.init = function(id){
  if(id){
    OrderPreview.initMsg(id);
  }
}
//初始化按钮
OrderPreview.initBtn = function(){
	$('.wafer-tab li').click(function(){
		var index = $(this).index();
		$('.wafer-tab li').removeClass('active');
		$(this).addClass('active');
    $('.wafer-tab-info li').eq(index).show().siblings().hide();
    $('.wafer-file').addClass('hidden');
    $('.wafer-file').eq(index).removeClass('hidden');
	})
};
//跳转支付
OrderPreview.toOrderPay = function(id){
	window.location.href = "/index.html#/pay_preview?id="+id;
};
//初始化数据
OrderPreview.initMsg = function(id){
  $("#id").val(id);
  var param = {
    url: 'shop/order/' + id,
    ajaxType: 'GET'
  }
  doInvoke(param, function(data) {
    if (data.code == code10000) {
      $("#orderDetail").empty().append($("#orderDetail-Template").render(data.data));
      OrderPreview.initBtn();
    }else{
    	errorAlert(data.message);
    }
  });


};

var serviceTypeImgArray = ['img_order_quick_pack','img_order_design_make','img_order_customized_service'];
var serviceTypeNameArray = ['快速封装','快速设计及制造','定制化服务'];
var packageTypeArray = ['BGA','LGA','QFN','QFP','其他封装模式'];
var baseSizeWayArray = ['客户指定','长芯指定'];
var ballSizeArray =['0.25','0.3','0.4','0.45','0.5','0.6','0.7'];//球大小
var fameWayArray =['全镀','环镀','NA'];
var substrateLayers =['2L','3L','4L','5L','6L','7L','8L','9L','10L'];
var waferSizeArray = [6, 8, 12];
var platingMaterialsArray = ['AL', 'ENEPIG', 'Au', 'Cu'];
var waferPackageWayArray = ['未研磨裸片', 'Die Form (Tray包装)', '附膜已切割'];
var readRayArray = ['Mapping', 'Ink Mark', '盲抓生产'];
var waferMaterialsArray = ['SI', 'Cu - Low K', 'GaAs', 'SiC', 'GaN'];

var bondingWayArray =['Wire Bond','Flip Chip','Wire Bond + Flip Clip'];//bonding方式
var plasticWayArray = ['Underfill','Transfer Mold','Underfill+Transfer Mold','NO'];//塑封方式
var sputteringArray = ['NO','YES'];//表面溅射
var packageWayArray = ['Tray','Tube','Reel'];//包装方式
var testTypeArray = ['功能','开短路','无需测试'];//Test测试项目
var testWayArray = ['抽测','全测'];//测试方式
var markArray = ['激光打标','油墨印字','激光打标+油墨印字'];//mark打标方式
var mslArray = ['MSL3','MSL2 A','MSL2','MSL1','不需要'];//MSL等级
var impactArray = ['100次','200次','500次','1000次','不需要'];//冷热冲击(-65~150℃)
var cycleArray = ['条件B','条件C','不需要'];//温度循环JESD22-A104
var storage125Array = ['48H','96H','168H','1000H','不需要'];//高温储存-125度条件
var storage150Array =['48H','96H','168H','1000H','不需要'];//150度条件下
var emulateArray = ['电磁仿真','热仿真','应力仿真','不需要'];//仿真要求
var otherTestArray = ['UHAST: 121℃，湿度100%，气压205Kpa，时间96H','可焊性测试','跌落测试','盐雾测试JESD22-A107C','不需要UHAST','不需要可焊性测试','不需要跌落测试','不需要盐雾测试'];//其他测试
var temperatureArray = ['民用：-20 ~ 40','军用：-40 ~ 85'];//工作温度(℃)
var espBodyArray = ['0 - 1999','2000 - 3999','4000 - 15999','不需要'];//人体模型
var espLitterArray = ['＜ 125','125 - 250','250 - 500','500 - 1000','不需要'];//带电模型

$.views.helpers({
  "mFileType":function(name){
    var nameArr = name.split(".");
    fileType = nameArr[nameArr.length-1].toUpperCase();;
      if(fileType == 'DOC' || fileType == 'DOCX'){
        return 'icon-doc';
      }else if(fileType == 'DWG'){
        return 'icon-dwg';
      }else if(fileType == 'DXF'){
        return 'icon-dxf';
      }else if(fileType == 'JPG'){
        return 'icon-jpg';
      }else if(fileType == 'PDF'){
        return 'icon-pdf';
      }else if(fileType == 'RAR'){
        return 'icon-rar';
      }else if(fileType == 'TXT'){
        return 'icon-txt';
      }else if(fileType == 'XLS' || fileType == 'XLSX'){
        return 'icon-xls';
      }else if(fileType == 'ZIP'){
        return 'icon-zip';
      }else{
        return 'icon-jpg';
      }
  },
  "substrateLayers":function(i){
    return substrateLayers[i];
  },
  "mServiceTypeImg":function(i){
    return serviceTypeImgArray[i];
  },
  "mServiceTypeName":function(i){
	return serviceTypeNameArray[i];
  },
  "mPackageType":function(i) {
    return isNull(i)?'无':packageTypeArray[i];
  },
  "mBaseSizeWay":function(i) {
    return isNull(i)?'':(' . '+baseSizeWayArray[i]);
  },
  "mBallSize":function(i){
	  return isNull(i)?'无':ballSizeArray[i];
  },
  "mFrameWay":function(i) {
    return isNull(i)?'无':fameWayArray[i];
  },
  "mWaferSize": function(i) {
    return isNull(i)?'无':waferSizeArray[i];
  },
  "mPlatingMaterials": function(i) {
    return isNull(i)?'无':platingMaterialsArray[i];
  },
  "mWaferPackageWay": function(i) {
    return isNull(i)?'无':waferPackageWayArray[i];
  },
  "mReadRay": function(i) {
    return isNull(i)?'无':readRayArray[i];
  },
  "mWaferMaterials": function(i) {
    return isNull(i)?'无':waferMaterialsArray[i];
  },
  'mSubContent': function(content, length) {
    return subContent(content, length);
  },
  'mFormatPhone': function(phone) {
    return formatPhone(phone);
  },
  'mBondingWay':function(i){
    return isNull(i)?'无':bondingWayArray[i];
  },
  'mPlasticWay':function(i){
    return isNull(i)?'无':plasticWayArray[i];
  },
  'mSputtering':function(i){
    return isNull(i)?'无':sputteringArray[i];
  },
  'mPackageWay':function(i){
    return isNull(i)?'无':packageWayArray[i];
  },
  'mTestType':function(i){
    return isNull(i)?'无':testTypeArray[i];
  },
  'mTestWay':function(i){
    return isNull(i)?'无':testWayArray[i];
  },
  'mMark':function(i){
    return isNull(i)?'无':markArray[i];
  },
  'mMsl':function(i){
	if(isNull(i)) return '无';
    var attr = new Array();
    $.each(mslArray,function(index,value){
         if(i.indexOf(index) != -1){
           attr.push(value);
         }
    });
    return attr.join("、");
  },
  'mImpact':function(i){
	if(isNull(i)) return '无';
    var attr = new Array();
    $.each(mslArray,function(index,value){
         if(i.indexOf(index) != -1){
           attr.push(value);
         }
    });
    return attr.join("、");
  },
  'mCycle':function(i){
	if(isNull(i)) return '无';
    var attr = new Array();
    $.each(cycleArray,function(index,value){
         if(i.indexOf(index) != -1){
           attr.push(value);
         }
    });
    return attr.join("、");
  },
  'mStorage125':function(i){
	if(isNull(i)) return '无';
    var attr = new Array();
    $.each(storage125Array,function(index,value){
         if(i.indexOf(index) != -1){
           attr.push(value);
         }
    });
    return attr.join("、");
  },
  'mStorage150':function(i){
	if(isNull(i)) return '无';
    var attr = new Array();
    $.each(storage150Array,function(index,value){
         if(i.indexOf(index) != -1){
           attr.push(value);
         }
    });
    return attr.join("、");
  },
  'mEmulate':function(i){
	  if(isNull(i)) return '无';
	  var attr = new Array();
	    $.each(emulateArray,function(index,value){
	         if(i.indexOf(index) != -1){
	           attr.push(value);
	         }
	    });
	    return attr.join("、");
  },
  'mOtherTest':function(i){
	  if(isNull(i)) return '无';
	  var attr = new Array();
	    $.each(otherTestArray,function(index,value){
	         if(i.indexOf(index) != -1){
	           attr.push(value);
	         }
	    });
	    return attr.join("、");
  },
  "mTemperature":function(i){
	  return isNull(i)?'无':temperatureArray[i];
  },
  "mEspBody":function(i){
	  return isNull(i)?'无':espBodyArray[i];
  },
  "mEspLitter":function(i){
	  return isNull(i)?'无':espLitterArray[i];
  },
  "mFormatDate":function(time){
	  return formatDate(time);
  },
  "mFormatMoney":function(money){
	  return formatMoney(money);
  }
});
